package com.simpleim.starter.protoBuilder;

import com.simpleim.common.ProtoInstant;
import com.simpleim.im.common.bean.msg.ProtoMsg;
import org.springframework.stereotype.Service;

@Service
public class LoginResponceBuilder {

    public ProtoMsg.Message loginResponse(ProtoInstant.ResultCodeEnum resultCode, long sequenceId, String sessionId) {
        ProtoMsg.Message.Builder builder = ProtoMsg.Message.newBuilder();
        ProtoMsg.LoginResponse loginResponse = ProtoMsg.LoginResponse.newBuilder()
            .setCode(resultCode.getCode())
                .setExpose(1)
                .setResult(true)
                .setInfo(resultCode.getDesc()).build();

        builder.setLoginResponse(loginResponse)
                .setSequence(sequenceId)
                .setSessionId(sessionId)
                .setType(ProtoMsg.HeadType.LOGIN_RESPONSE);
        return builder.build();
    }
}
